/*
 * @Author: TT-hzy 
 * @Date: 2024-05-05 16:03:13
 * @LastEditors: TT-hzy 
 * @LastEditTime: 2024-05-14 10:44:22
 * @Description: 
 */
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../common/app_router_observer.dart';
import '../config/routers/routers.dart';
import '../config/theme_config/theme_data_config.dart';

/// 6.1
Size screenSize = const Size(390, 844);

/// 4.7
Size screenIphone7 = const Size(375, 667);

/// 5.8
Size screenIphoneX = const Size(375, 812);

/// 初始化 GetX
Widget initGetMaterialApp({
  Widget Function(BuildContext, Widget?)? builder,
}) {
  return MaterialApp(
    /// 入口路由
    initialRoute: RouterS.configNoramlRouts(),

    /// 主题配置
    theme: themeDataLight,

    /// 暗黑主题配置
    darkTheme: themeDataDark,

    /// 路由观察者
    navigatorObservers: [
      AppRouterObserver().routeObserver,
    ],

    /// 所有路由集合
    routes: RouterS.getAllRoutS(),

    /// 是否显示 导航栏右上角 debug 标识
    debugShowCheckedModeBanner: false,

    /// 页面构建器
    builder: builder,
  );
}

/// 初始屏幕适配
Widget initScreenUtil({
  required Widget Function(BuildContext, Widget?) builder,
  bool useInheritedMediaQuery = true,
}) {
  return ScreenUtilInit(
    /// UI尺寸
    designSize: screenSize,
    useInheritedMediaQuery: useInheritedMediaQuery,
    minTextAdapt: true,
    splitScreenMode: true,
    builder: builder,
  );
}

/// 初始化App
Widget initRunApp() {
  Widget body = initGetMaterialApp(builder: (context, child) {
    return initScreenUtil(
      builder: (p0, p1) {
        return child!;
      },
    );
  });
  return body;
}
